<template>
<div class="app-con">
  <table class="table table-bordered table-condensed">
    <!-- <caption style="color: red;">金丹销售提成表:</caption> -->
    <tr>
      <td>业务员: {{tempData.yewuyuan}}</td>
      <td colspan="3" style="text-align: center;">金丹销售提成表</td>
      <td>收款协议：{{tempData.shoukuanxieyi}}</td>
      <td>打托缠膜: {{tempData.chanmofeiyong}}</td>
    </tr>
    <tr>
      <td>单号 {{tempData.danjuhao}}</td>
      <td>单据日期: {{tempData.danjuriqi}}</td>
      <td>含税单价: {{tempData.hanshuidanjia}}</td>
      <td>运输方式: {{tempData.fangshi}}</td>
      <td>收获客户: {{tempData.shouhuokehu}}</td>
      <td>物料名称: {{tempData.wuliaomingcheng}}</td>
    </tr>
    <tr>
      <td>包装物: {{tempData.bzw}}</td>
      <td>数量: {{tempData.shuliang}}</td>
      <td>价税合计: {{tempData.jiashuiheji}}</td>
      <td>运输单价: {{tempData.yunshudanjia}}</td>
      <td>包装单价: {{tempData.domesticBaozhuang.buhanbaozhuang}}</td>
      <td>新客户：{{tempData.shifouweixinkehu}}</td>
    </tr>
    <tbody v-for="(item,index) in tempData.huikuanList" :key="index">
      <tr>
        <td>客户回款金额: {{item.jine2}}</td>
        <td>客户余额: {{item.jine}}</td>
        <td>回款日期：{{item.huikuanriqi}}</td>
        <td>承兑日期: {{item.chengduiriqi}}</td>
        <td>佣金: {{tempData.yongjin}}</td>
        <td>佣金返点: {{tempData.yongjinbili}}</td>
      </tr>
      <tr>
        <td colspan="4" v-if='item.xiankuanjiangbili != 0'>先款奖: ( {{tempData.hanshuidanjia}} - {{tempData.yunshudanjia}} - {{tempData.domesticBaozhuang.buhanbaozhuang}} {{tempData.yongjin ? '-'+tempData.yongjin:''}} {{tempData.yongjinbili ? '-'+tempData.yongjinbili*tempData.hanshuidanjia : ''}}{{tempData.chanmofeiyong ? '-'+tempData.chanmofeiyong : ''}} ) * {{item.xiankuanjiangbili}} * {{tempData.shuliang}} </td>
        <td colspan="4" v-else>先款奖: {{item.xiankuanjiang}}</td>
        <td>先款奖: {{item.xiankuanjiang}}</td>
        <td>实际使用金额：{{item.shijishiyongjine}}</td>
      </tr>
      <tr>
        <td colspan="4" v-if="item.lixijiangbili == '0.01/30*0.4'">利息奖: {{item.yufutianshu}} * ( {{tempData.hanshuidanjia}} - {{tempData.yunshudanjia}} - {{tempData.domesticBaozhuang.buhanbaozhuang}}{{tempData.yongjin ? '-'+tempData.yongjin:''}} {{tempData.yongjinbili ? '-'+tempData.yongjinbili*tempData.hanshuidanjia : ''}}{{tempData.chanmofeiyong ? '-'+tempData.chanmofeiyong : ''}} ) * {{item.lixijiangbili}} * {{tempData.shuliang}}</td>
        <td colspan="4" v-if="item.lixijiangbili == '0.01/30*0.04'">利息奖: {{item.yufutianshu}} * ( {{tempData.hanshuidanjia}} - {{tempData.yunshudanjia}} - {{tempData.domesticBaozhuang.buhanbaozhuang}}{{tempData.yongjin ? '-'+tempData.yongjin:''}} {{tempData.yongjinbili ? '-'+tempData.yongjinbili*tempData.hanshuidanjia : ''}}{{tempData.chanmofeiyong ? '-'+tempData.chanmofeiyong : ''}} ) * {{item.lixijiangbili}} * {{tempData.shuliang}}</td>
        <td colspan="4" v-if="item.lixijiangbili == '0.01/30*0.05'">利息奖: {{item.yufutianshu}} * ( {{tempData.hanshuidanjia}} - {{tempData.yunshudanjia}} - {{tempData.domesticBaozhuang.buhanbaozhuang}}{{tempData.yongjin ? '-'+tempData.yongjin:''}} {{tempData.yongjinbili ? '-'+tempData.yongjinbili*tempData.hanshuidanjia : ''}}{{tempData.chanmofeiyong ? '-'+tempData.chanmofeiyong : ''}} ) * {{item.lixijiangbili}} * {{tempData.shuliang}}</td>
        <td>利息奖: {{item.lixijiang}}</td>
        <td colspan="2"></td>
      </tr>
    </tbody>
    <tbody v-if="tempData.huikuanList.length == 0">
      <tr>
        <td colspan="4">先款奖: 0</td>
        <td>先款奖: 0</td>
        <td>实际使用金额：</td>
      </tr>
      <tr>
        <td colspan="4">利息奖: 0</td>
        <td>利息奖: 0</td>
        <td colspan="2"></td>
      </tr>
    </tbody>
    <tr>
      <!-- 提成比例 * 净水金额 * 吨位 -->
      <td colspan="4" v-if='tempData.jijiatichengbili == 0.0015'>基价提成:{{tempData.jijiatichengbili}} * （{{tempData.hanshuidanjia}} - {{tempData.yunshudanjia}} - {{tempData.domesticBaozhuang.buhanbaozhuang}}{{tempData.yongjin ? '-'+tempData.yongjin:''}} {{tempData.yongjinbili ? '-'+tempData.yongjinbili*tempData.hanshuidanjia : ''}}{{tempData.chanmofeiyong ? '-'+tempData.chanmofeiyong : ''}}） * {{tempData.shuliang}}</td>
      <!-- 提成比例 * 净水金额 * 吨位 -->
      <td colspan="4" v-if='tempData.jijiatichengbili == 0.0035'>基价提成:{{tempData.jijiatichengbili}} * （{{tempData.hanshuidanjia}} - {{tempData.yunshudanjia}} - {{tempData.domesticBaozhuang.buhanbaozhuang}}{{tempData.yongjin ? '-'+tempData.yongjin:''}} {{tempData.yongjinbili ? '-'+tempData.yongjinbili*tempData.hanshuidanjia : ''}}{{tempData.chanmofeiyong ? '-'+tempData.chanmofeiyong : ''}}） * {{tempData.shuliang}}</td>
      <!-- 提成比例 * 净水金额 * 吨位 -->
      <td colspan="4" v-if='tempData.jijiatichengbili == 0.002'>基价提成:{{tempData.jijiatichengbili}} * （{{tempData.hanshuidanjia}} - {{tempData.yunshudanjia}} - {{tempData.domesticBaozhuang.buhanbaozhuang}}{{tempData.yongjin ? '-'+tempData.yongjin:''}} {{tempData.yongjinbili ? '-'+tempData.yongjinbili*tempData.hanshuidanjia : ''}}{{tempData.chanmofeiyong ? '-'+tempData.chanmofeiyong : ''}}） * {{tempData.shuliang}}</td>
      <!-- 提成比例 * 净水金额 * 吨位 -->
      <td colspan="4" v-if='tempData.jijiatichengbili == 0.004'>基价提成:{{tempData.jijiatichengbili}} * （{{tempData.hanshuidanjia}} - {{tempData.yunshudanjia}} - {{tempData.domesticBaozhuang.buhanbaozhuang}}{{tempData.yongjin ? '-'+tempData.yongjin:''}} {{tempData.yongjinbili ? '-'+tempData.yongjinbili*tempData.hanshuidanjia : ''}}{{tempData.chanmofeiyong ? '-'+tempData.chanmofeiyong : ''}}） * {{tempData.shuliang}}</td>
      <!-- 提成比例 * 第五档基价 + 价税比例 *（净水金额 - 第五档基价）* 吨位 -->
      <td colspan="4" v-if='tempData.jijiatichengbili == 0.0045'>基价提成:({{tempData.jijiatichengbili}} * {{tempData.domesticJijiabiao.diwudang}} + {{tempData.domesticXishu.jingshui3b}}*({{tempData.hanshuidanjia}} - {{tempData.yunshudanjia}} - {{tempData.domesticBaozhuang.buhanbaozhuang}} - {{tempData.domesticJijiabiao.diwudang}}{{tempData.yongjin ? '-'+tempData.yongjin:''}} {{tempData.yongjinbili ? '-'+tempData.yongjinbili*tempData.hanshuidanjia : ''}}{{tempData.chanmofeiyong ? '-'+tempData.chanmofeiyong : ''}})) * {{tempData.shuliang}}</td>
      <!-- 提成比例 * 第五档基价 + 价税比例 *（净水金额 - 第五档基价）* 吨位 -->
      <td colspan="4" v-if='tempData.jijiatichengbili == 0.006'>基价提成:({{tempData.jijiatichengbili}} * {{tempData.domesticJijiabiao.diwudang}} + {{tempData.domesticXishu.xinkehu3b}}*({{tempData.hanshuidanjia}} - {{tempData.yunshudanjia}} - {{tempData.domesticBaozhuang.buhanbaozhuang}} - {{tempData.domesticJijiabiao.diwudang}}{{tempData.yongjin ? '-'+tempData.yongjin:''}} {{tempData.yongjinbili ? '-'+tempData.yongjinbili*tempData.hanshuidanjia : ''}}{{tempData.chanmofeiyong ? '-'+tempData.chanmofeiyong : ''}})) * {{tempData.shuliang}}</td>
      <td colspan="4" v-if='tempData.jijiatichengbili == 0'>基价提成:0</td> 
      <td colspan="2">基价提成: {{tempData.jijiaticheng}}</td>
    </tr>
    <tr>
      <td colspan="4">计算日期:{{tempData.jisuanriqi}}</td>
      <td colspan="2">合计: {{heji}}</td>
    </tr>
  </table>
<div class="container-fluid">
  <div class="foot1">制表人：罗智慧</div>
  <div class="foot1">制表人：</div>
  <div class="foot1">审核人：</div>
  <div class="foot1">审批人：</div>
</div>
</div>
</template>

<script>
import { idSearchDetail,updateFahuo } from "@/api/neimao"
export default {
  data(){
    return{
      tempData: {
        domesticBaozhuang: {
          buhanbaozhuang: ''
        },
        domesticJijiabiao: {
          diwudang: ''
        }
      },
      heji: 0
    }
  },
  mounted(){
    console.log(this.$route.params)
    const temp = JSON.parse(this.$route.params.options)
    this.getdetail(temp.id)
  },
  methods:{
    getdetail(id){
      const loading = this.$loading({
        lock: true,
        text: '加载中请稍等...',
        spinner: 'el-icon-loading',
        background: 'rgba(255, 255, 255, 0.8)'
      })
      idSearchDetail(id).then(res => {
        console.log('res',res)
        this.tempData = res.data
        const hkje = res.data.huikuanList.reduce((total,current) => {
          return total+=current.lixijiang*1 + current.xiankuanjiang*1
        },0)
        this.heji = (hkje + res.data.jijiaticheng*1).toFixed(2)
        this.updateDayin(res.data)
        loading.close()
      }).catch(() => {
        loading.close()
      })
    },
    updateDayin(item){
      item.queren = '已打印'
      updateFahuo(item).then(res => {
        console.log(res)
      })
    }
  }
}
</script>

<style scoped>
 .table{
  width: 100%;
  border: 1px solid #000000; /* 整体表格边框 */
  border-collapse: collapse;
}
td{
  border: 1px solid #000000;
  font-size: 14px;
  padding: 5px;
}
.container-fluid{
  display: flex;
  align-items: center;
  border: 1px solid #000;
  border-top: none;
  padding: 5px 0;
}
.foot1{
  flex: 1;
  font-size: 14px;
}
</style>